#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>

#define MAX_EPOCH 10000

float worker_output = 0;
float master_output = 0;

void *worker(void *arg)
{
	int i;
	for(i = 0; i < MAX_EPOCH / 2; i++) {
		if(i % 2 == 0) worker_output += 1.0 / (2 * i + 1);
		else worker_output -= 1.0 / (2 * i + 1);
	}
	return NULL;
}

void master()
{
	int i;
	for(i = MAX_EPOCH / 2; i < MAX_EPOCH; i++) {
		if(i % 2 == 0) master_output += 1.0 / (2 * i + 1);
		else master_output -= 1.0 / (2 * i + 1);
	}
}

int main()
{
	pthread_t worker_tid;
	float total;

	pthread_create(&worker_tid, NULL, worker, NULL);
	master();
	pthread_join(worker_tid, NULL);
	total = (worker_output + master_output) * 4;
	printf("%f\n",total);
	return 0;
}
